import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class TEST {

    public static  int add(int a,int b){
        return  a+b;
    }
    public static  double add( double a,double b) {
    return a +b;
    }

        public static void main0(String[] args) {
        int a = 0;
        int b = 0;
        int ret =  add(3,5);
        System.out.println(ret);
    }

    public static void main1(String[] args) {
        Random random = new Random();
        int readNum = random.nextInt(100);
        Scanner scanner = new Scanner(System.in);
        System.out.println("===="+"猜数字"+"====");
        System.out.println("请输入数字；");
        while (true){
            int num = scanner.nextInt();
            if(num == readNum){
                System.out.println("猜对了");
                break;
            } else if (num > readNum) {
                System.out.println("猜大了");
            } else if (num < readNum) {
                System.out.println("猜小了");

            }
        }
    }

    public static int []fac(int []array,int target){
        int []ret  =  new int[]{-1,-1};
        for (int i = 0; i <array.length ; i++) {
            for (int j = 0; j <array.length ; j++) {
                if(array[i] + array[j] ==target){
                    ret [0] =j;
                    ret [1] = i;
                }

            }

        }
        return  ret ;
    }

    public static void main2(String[] args) {
        int [] arrary ={1,3,5,13};
        int []ret = fac(arrary,6);
        System.out.println(Arrays.toString(ret));

    }
public static void bubble_sort(int[]arrary){
    for (int i = 0; i <arrary.length -1; i++) {
        for (int j = 0; j <arrary.length-1 ; j++) {
            if (arrary[j]<arrary[j+1]) {
                int tmp = arrary[j];
                arrary[j] = arrary[j+1];
                arrary[j+1] = tmp;
            }

        }

    }
}
    public static void main4(String[] args) {
        //冒泡排序
        int[] arrary = {1,2,3,4,5,6,7,8,9};
        System.out.println(Arrays.toString(arrary));
        bubble_sort(arrary);
        System.out.println(Arrays.toString(arrary));

    }
public  static  int binraysearch(int [] arrary,int key){
        int left = 0;
        int right = arrary.length-1;
        while (left<=right){
            int mid =(right + left)/2;
            if(key<arrary[mid]){
               right = mid -1;
            } else if (key>arrary[mid]) {
              left = mid +1;
            } else if (key == arrary[mid]) {
                System.out.println("找到了"+arrary[mid]);
                System.out.print("下标是：");
                return mid;
            }

            }
                return -1;

        }

    public static void main5(String[] args) {
        int[] arrary = {1,3,4,5,6,7,8,9};
       int ret = binraysearch(arrary,3);
        System.out.println(ret);

    }
public static void changNum(int [] arrary) {
    int left = 0;
    int right = arrary.length - 1;
    while (left < right) {
        if (left < right && arrary[left] % 2 != 0) {
            left++;
        } else if (left < right && arrary[right] % 2 == 0) {
            right--;
        } else {
            int tmp =arrary[right];
            arrary[right] = arrary[left];
            arrary[left] = tmp;

            
        }
    }
    }
    public static void main(String[] args){
        //奇数偶数互换
        int[] arrary = {3, 4, 8, 9, 7, 1, 5};
        System.out.println(Arrays.toString(arrary));
        changNum(arrary);
        System.out.println(Arrays.toString(arrary));
    }

}
